package com.czk.config;

import com.czk.interfaces.WebServerFactory;
import org.apache.catalina.startup.Tomcat;
import org.springframework.stereotype.Component;

/**
 * 创建tomcat服务器
 *
 * @Author:ChenZhangKun
 * @Date: 2021/4/27 17:15
 */
@Component
public class TomcatServer implements WebServerFactory {
    @Override
    public void crateServer() throws Exception {
        // 定义tomcat服务器
        Tomcat tomcat = new Tomcat();
        // 设置端口
        tomcat.setPort(8888);
        // 启动
        tomcat.addWebapp("/","E://tomcat"); // 完成监听
        tomcat.start();
        //
        tomcat.getServer().await();
    }
}
